package com.som.blog.config;

import org.springframework.context.support.GenericApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

/**
 * @author som
 */
public final class ApplicationConfig {

    /**
     * Loading Spring configs and creating context
     *
     * @return Spring application context
     */
    public static GenericApplicationContext getApplicationContext() {
        GenericXmlApplicationContext springAppContext = new GenericXmlApplicationContext();
        //TODO: move from code to configs. Read from properties
        springAppContext.load("classpath*:/com/som/blog/*-config.xml",
                "classpath*:/com/som/blog/service/*-config.xml",
                "classpath*:com/som/blog/datasource/*-config.xml");
        springAppContext.refresh();
        return springAppContext;
    }

}
